clear all
clc

cd('../../../../cvx_2.2.2')
cvx_setup

warning('off','MATLAB:nargchk:deprecated')
warning('off','MATLAB:illConditionedMatrix')

cd('../bernstein_simulations/J3/codes')

zeta_table

%% DGP: random search

J = 3;    % # of goods
N = 20000;  % # of individuals

alpha = 1;
beta = 1;

mu_x = 0;
mu_z = 0;

sigma_x = 1;
sigma_z = 1;

mu_c = -2;
sigma_c = 1.5;

%% PREP FOR ESTIMATION

m_regr = [3 4 3*ones(1,J-2) 4 4 3*ones(1,J-2)];

[combos_all_unique] = combinations_10(m_regr,J);

% constraints

[Aineq,bineq] = constraint_mat_theta_2(combos_all_unique,J);

Aeq = [];
beq = [];

ntheta = size(Aineq,2);

ss=71;

rng(10101010*ss+ss^2)

tic

[data,data_trans] = generate_data_weitz(N,J,mu_x,sigma_x,mu_z,sigma_z,alpha,beta,mu_c,sigma_c,input_list,output_list);

%% ESTIMATION ROUTINE

[theta_NPD,fval_NPD,flag_NPD] = estimation_NPD_cvx(data_trans,J,N,m_regr,Aineq,Aeq,bineq,beq,...
    combos_all_unique,ntheta);

toc

save('../results/weitzman/MC_71.mat')

script_ratio

clear data* bineq Aineq input_list output_list

save('../results/weitzman/MC_71.mat')



